<?php
namespace app\personal\controller;

use think\Controller;
use think\Db;

class Index extends Controller
{
    /**
     * 显示收藏列表
     *
     *@return user/index
     */
    public function index()
    {
        $house = Db::table(['images', 'article', 'user_self', 'house'])
            ->field('images.iname,house.id,article.aid,article.aname, article.regtime,user_self.nickname')
            ->where('article.aid=images.iid and house.aid=article.aid and article.uid=user_self.uid and house.uid = 2')
            ->select();
//        dump($house);

        return view('index/index', [
            'title' => '【众评网】为你私人定制的资讯客户端 --- 【che-cn.com】 - 个人中心',
            'house' => $house,
        ]);
    }

    /**
     * 取消收藏
     * @param $id  收藏id
     * @return \think\response\Json
     */
    public function delete($id)
    {
        $result = Db::table('house')->delete($id);
        return json($result);
    }

    /**
     * 添加收藏
     * @param $id
     * @return \think\response\Json
     */
    public function create($id)
    {
        $data = hehe;
        $result = Db::table('house')->data($data)->insert();
        return json($result);
    }

}